<?php

namespace Admin\Model;

use Think\Model;

/**
* 
*/
class FeedbackModel extends Model
{
	/**
	 * [courselist description]
	 * @param  string $record 是否记录 0未记录，1已记录
	 * @return [type]         [description]
	 */
	public function feedbackList($record = ''){
		$map['record'] = $record;
		$map['status'] = 1;

		//分页
		$count = $this -> where($map) -> count();
		$page = new \Think\Page($count, 10);
		$page -> setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
		$pages = $page -> show();
		
		$where['f.record'] = $record;
		$where['f.status'] = 1;

		$data = $this -> field('f.*,u.nickname') -> alias('f') -> join('tutor_user_member as u on f.uid=u.id') -> where($where) -> order('f.create_time desc') -> limit($page->firstRow, $page->listRows) -> select();
		return array($data,$pages);
	}

	public function edit($id,$val,$flag){
		$where['id'] = is_array($id) ? array('in',implode(',', $id)) : $id;
		return $this -> where($where) -> save(array($flag => $val));
	}
}